package com.library.mapper;

import com.library.entity.Book;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface BookMapper {
    @Select("SELECT * FROM book")
    List<Book> findAll();
    
    @Select("SELECT * FROM book WHERE id = #{id}")
    Book findById(Integer id);
    
    @Insert("INSERT INTO book(name, author, publish_date, isbn, stock, status) " +
            "VALUES(#{name}, #{author}, #{publishDate}, #{isbn}, #{stock}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Book book);
    
    @Update("UPDATE book SET name=#{name}, author=#{author}, publish_date=#{publishDate}, " +
            "isbn=#{isbn}, stock=#{stock}, status=#{status} WHERE id=#{id}")
    int update(Book book);
    
    @Delete("DELETE FROM book WHERE id=#{id}")
    int delete(Integer id);
} 